﻿/*----------------------------------------------------------------
//  <copyright file="WeChatTokenDto.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2022-11-15 14:42</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.Authentication.OAuth2.WeChat.Dtos
{
    #region "微信令牌信息Dto"
    /// <summary>
    /// 微信令牌信息Dto
    /// </summary>
    public class WeChatTokenDto
    {
        #region "属性"
        #region "获取或设置 接口调用凭证"
        /// <summary>
        /// 获取或设置 接口调用凭证
        /// </summary>
        public string AccessToken { get; set; }
        #endregion
        #region "获取或设置 access_token接口调用凭证超时时间，单位（秒）"
        /// <summary>
        /// 获取或设置 access_token接口调用凭证超时时间，单位（秒）
        /// </summary>
        public int? ExpiresIn { get; set; }
        #endregion
        #region "获取或设置 用户刷新access_token"
        /// <summary>
        /// 获取或设置 用户刷新access_token
        /// </summary>
        public string RefreshToken { get; set; }
        #endregion
        #region "获取或设置 授权用户标识，对该公众账号唯一"
        /// <summary>
        /// 获取或设置 授权用户标识，对该公众账号唯一
        /// </summary>
        public string OpenId { get; set; }
        #endregion
        #region "获取或设置 用户授权的作用域，使用逗号（,）分隔"
        /// <summary>
        /// 获取或设置 用户授权的作用域，使用逗号（,）分隔
        /// </summary>
        public string Scope { get; set; }
        #endregion
        #region "获取或设置 用户统一标识"
        /// <summary>
        /// 获取或设置 用户统一标识，针对一个微信开放平台帐号下的应用，同一用户的unionid是唯一的
        /// 当且仅当该网站应用已获得该用户的userinfo授权时，才会出现该字段
        /// </summary>
        public string UnionId { get; set; }
        #endregion

        #endregion

        #region "构造函数"
        #region "初始化一个微信令牌信息Dto的新实例"
        /// <summary>
        /// 初始化一个微信令牌信息Dto的新实例
        /// </summary>
        public WeChatTokenDto()
        { }
        #endregion
        #region "初始化一个微信令牌信息Dto的新实例"
        /// <summary>
        /// 初始化一个微信令牌信息Dto的新实例
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="expiresIn"></param>
        /// <param name="refreshToken"></param>
        /// <param name="openId"></param>
        /// <param name="scope"></param>
        /// <param name="unionId"></param>
        public WeChatTokenDto(string accessToken, int? expiresIn, string refreshToken, string openId, string scope, string unionId)
        {
            AccessToken = accessToken;
            ExpiresIn = expiresIn;
            RefreshToken = refreshToken;
            OpenId = openId;
            Scope = scope;
            UnionId = unionId;
        }
        #endregion
        #region "初始化一个微信令牌信息Dto的新实例"
        /// <summary>
        /// 初始化一个微信令牌信息Dto的新实例
        /// </summary>
        /// <param name="jObject"></param>
        public WeChatTokenDto(JObject jObject)
        {
            AccessToken = jObject?.Value<string>("access_token");
            ExpiresIn = jObject?.Value<int>("expires_in");
            RefreshToken = jObject?.Value<string>("refresh_token");
            OpenId = jObject?.Value<string>("openid");
            Scope = jObject?.Value<string>("scope");
            UnionId = jObject?.Value<string>("unionid");

        }
        #endregion

        #endregion

    }
    #endregion

}
